实现了 增删改查
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><%String path = request.getContextPath();String basePath = request.getScheme() "://" request.getServerName() ":" request.getServerPort() path "/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head><script type="text/javascript" src="<%=path %>/js/jquery-1.8.2.min.js"></script><link rel="stylesheet" href="<%=path %>/css/index2.css" type="text/css"></link><script type="text/javascript" src="<%=path %>/My97DatePicker/WdatePicker.js"></script> </head> <script type="text/javascript"> $(function(){ $.ajax({ url:"<%=path%>/student/queryad.do", dataType:"json", type:"post", success:function(obj){ var alist=obj.alist; alert(alist); for ( var i in alist) {$("#aid").append("<option value='" alist[i].aid "'>" alist[i].aname "</option>");} } }); }); function add(){ $.ajax({url:"<%=path%>/student/add.do",data:$("form").serialize(),dataType:"json",type:"post",success:function(obj){if(obj.code=='success'){alert("添加成功!");location.href="<%=path%>/student/list.do";}else{alert("添加失败!");}} }); } </script> <body> <form> <table> <tr> <th> 名称:<input type="text" name="name" id="name"/> </th> </tr> <tr> <th> 生日:<input type="text" readonly="readonly" name="birthday" id="birthday" onclick="WdatePicker()"/> </th> </tr> <tr> <th> 地址: <select id="aid" name="aid"> </select> </th> </tr> <tr> <th> <input type="button" value="添加" onclick="add()"/> </th> </tr> </table> </form> </body></html>
评论